#include<stdio.h>
int main() {
    int m,i,c,count;
    scanf("%d",&m);
    int arr[500000];
    scanf("%d",&count);
    for (i = 0; i < m; i++) {
        scanf("%d",&c);
        arr[i] = c;
    }  
    for (i = 0; i <count; i++) {
        int start,end,score;
        scanf("%d",&start);
        scanf("%d",&end);
        scanf("%d",&score);
        for (int j = start -1; j <= end -1;j++)
          arr[j]=arr[j]+score;
    }
    int min=arr[0];
      for (i = 0; i < m; i++) {
        if(arr[0]>arr[i])
        min=arr[i];
    }
    printf("%d",min);
}
